package com.zhousb.file_retrieval_server.aspect;


import com.zhousb.file_retrieval_server.exception.CustomerException;
import com.zhousb.file_retrieval_server.utils.AuthUtils;
import jakarta.annotation.Resource;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
 * @author ZhouShenBin
 * @date 2024/3/14 14:17
 * @description
 */
@Component
@Aspect
public class SuperValidAspect {

    @Resource
    AuthUtils authUtils;

    @Before("@annotation(com.zhousb.file_retrieval_server.aop.SuperValid)")
    public void beforeSuperValid(JoinPoint joinPoint) {
        if (!authUtils.isSuperAdmin()) {
            throw new CustomerException("无权访问");
        }
    }
}
